package day22.Compare;

public class Ship implements Comparable {

	private int capacity;
	private int crew;
	private int numSavingBoats;
	private String shipName;
	private String captain;

	public Ship() {
		shipName = "";
		captain = "";
	}

	public Ship(int capacity, int crew, String shipName) {
		super();
		this.capacity = capacity;
		this.crew = crew;
		this.shipName = shipName;
	}

	public int getCapacity() {
		return capacity;
	}

	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}

	public int getCrew() {
		return crew;
	}

	public void setCrew(int crew) {
		this.crew = crew;
	}

	public int getNumSavingBoats() {
		return numSavingBoats;
	}

	public void setNumSavingBoats(int numSavingBoats) {
		this.numSavingBoats = numSavingBoats;
	}

	public String getShipName() {
		return shipName;
	}

	public void setShipName(String shipName) {
		this.shipName = shipName;
	}

	public String getCaptain() {
		return captain;
	}

	public void setCaptain(String captain) {
		this.captain = captain;
	}

	@Override
	public int compareTo(Object anotherShip) {
		if ((anotherShip != null) && (anotherShip instanceof Ship))
			// return this.capacity - ((Ship)anotherShip).capacity; //->sort by
			// capacity
			// return this.shipName.compareTo(((Ship)anotherShip).shipName); //
			// - sort by first letterof the ship name
			return this.capacity * this.crew - ((Ship) anotherShip).capacity
					* ((Ship) anotherShip).crew;
		return 1;
	}
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return this.shipName;
	}

}
